package com.gitee.sidihuo.sse;


import com.gitee.sidihuo.sse.base.SseHttpResponseFunction;

import java.util.ArrayList;
import java.util.concurrent.CountDownLatch;

/**
 *
 */
public class SseOkHttpParaBuilder<T> {
    public static <T> SseOkHttpPara<T> buildSseOkHttpPara(String id, SseHttpResponseFunction<T> sseHttpResponseFunction) {
        SseOkHttpPara<T> para = new SseOkHttpPara();
        para.setId(id);
        para.setSseEmitter(SseContextHolder.getInstance().getSseEmitter(id));
        para.setCountDownLatch(new CountDownLatch(1));
        para.setSseHttpResponseFunction(sseHttpResponseFunction);
        para.setStreamResults(new ArrayList<>());
        para.setStreamOriginResults(new ArrayList<>());
        return para;
    }

}
